import {createInertiaApp} from '@inertiajs/vue3';
import {resolvePageComponent} from 'laravel-vite-plugin/inertia-helpers';
import {createApp, h} from 'vue';
import ArcoVue from '@arco-design/web-vue';
import ArcoVueIcon from '@arco-design/web-vue/es/icon'
import '@arco-design/web-vue/dist/arco.css';
import 'animate.css';
import '../../css/app.css'
import '@/assets/styles/app.css'
import {ZiggyVue} from 'ziggy-js';

const appName = '预约收银';

createInertiaApp({
    title: (title) => title ? `${title}` : appName,
    resolve: resolvePage,
    setup({el, App, props, plugin}) {
        createApp({render: () => h(App, props)})
            .use(plugin)
            .use(ArcoVue)
            .use(ArcoVueIcon)
            .use(ZiggyVue)
            .mount(el);
    },
    progress: {
        color: '#1890ff',
    },
}).catch(reason => {
    console.log(reason);
});


function resolvePage(name) {
    const pages = import.meta.glob('../pages/web/**/*.vue');
    if (pages[`../pages/web/${name}.vue`]){
        return resolvePageComponent(`../pages/web/${name}.vue`, pages);
    }
    // 添加默认返回或错误处理
    throw new Error(`Page not found: ${name}`);
}
